package com.jisu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jisu.dto.DealerDTO;
import com.jisu.mapper.DealerMapper;
import com.jisu.pojo.Dealer;
import com.jisu.service.DealerService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

@Service
public class DealerServiceImpl extends ServiceImpl<DealerMapper, Dealer> implements DealerService {
    @Override
    public List<Dealer> searchDealersByDTO(DealerDTO dealerDTO) {
        return this.baseMapper.selectList(new LambdaQueryWrapper<Dealer>()
                .like(StringUtils.hasText(dealerDTO.getDealerName()), Dealer::getDealerName, dealerDTO.getDealerName())
                .like(StringUtils.hasText(dealerDTO.getDealerAddress()), Dealer::getDealerAddress, dealerDTO.getDealerAddress())
                .like(StringUtils.hasText(dealerDTO.getDealerPhone()), Dealer::getDealerPhone, dealerDTO.getDealerPhone()));
    }
}
